package com.chenjt.netty.thirteen_handler;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

/**
 * 注释：自定义编码器（出站处理器），要继承MessageToByteEncoder
 *
 * @author chenjt
 * @date 2024/9/6 14:26
 */
public class MyLongToByteEncoder extends MessageToByteEncoder<Long> {

    @Override
    protected void encode(ChannelHandlerContext channelHandlerContext, Long msg, ByteBuf out) throws Exception {
        System.out.println("encode invoked!");

        System.out.println(msg);

        out.writeLong(msg);

    }
}
